package gang.org.springframework.boot.autoconfigure.web.servlet;

import gang.org.springframework.framework.core.GangConventions;

import javax.servlet.Registration;
import javax.servlet.ServletContext;

/**
 * @Author：gang.chen
 * @Date：2023/10/13 9:29
 */
public abstract class GangDynamicRegistrationBean<D extends Registration.Dynamic> extends GangRegistrationBean {


    private String name;

    public final String getOrDeduceName(Object value){

        return this.name != null ? this.name : GangConventions.getVariableName(value);
    }

    public void setName(String name){
        this.name = name;
    }

    @Override
    protected final void register(String description, ServletContext servletContext){

        D registration = addRegistration(description, servletContext);

        //if( registration == null)

        configure(registration);
    }

    public abstract D addRegistration(String description, ServletContext servletContext);


    public void configure(D registration){
        //TODO
    }

}
